package com.cy.pj.ajax.controller;


import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController

public class AjaxLibController {

    @PostMapping("/doPostJSON")

    public  String doPostJSON(@RequestBody Map<String,Object> map){

        System.out.println("map="+map);
        return "post ok";
    }

    @PostMapping("/doPost")
    //使用map作为参数接收
    //@RequestBody
    public  String doPost(@RequestParam Map<String,Object> map){

        System.out.println("map="+map);
        return "post ok";
    }

    @GetMapping("/doGet")
    public Map<String,Object>  doGet(){
        Map<String,Object> map=new HashMap<>();
        map.put("code",1);
        map.put("message","success");
        return map;
    }

    @RequestMapping("/doAjax")
    public  String doAjax(String msg){
        System.out.println("msg="+msg);
        return  msg+".toUpperCase():"+msg.toUpperCase();
    }
}
